package com.fjut.wx.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjut.model.vod.Course;
import com.fjut.result.Result;
import com.fjut.service.CourseService;
import com.fjut.vo.vod.CourseQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "公众号课程接口")
@RestController
@RequestMapping("/fjut/vod/course")
public class CourseApiController {

    @Autowired
    private CourseService courseService;

    @ApiOperation("模糊查询课程名")
    @GetMapping("getClientCourseLike/{keyWord}")
    public List<Course> getClientCourseLike(@PathVariable String keyWord) {
        return courseService.getCourseLike(keyWord);
    }

    @ApiOperation("根据课程分类查询课程列表")
    @GetMapping("getCourseListByType/{subjectParentId}/{page}/{limit}")
    public Result getCourseListByType(@PathVariable Long subjectParentId,@PathVariable Long page,@PathVariable Long limit){
        CourseQueryVo courseQueryVo = new CourseQueryVo();
        courseQueryVo.setSubjectParentId(subjectParentId);
        Page<Course> coursePage = new Page<>(page, limit);
        return Result.success(courseService.getCourseListByType(courseQueryVo,coursePage));
    }

    @ApiOperation("根据课程id查询课程详情")
    @GetMapping("getCourseInfoById/{id}")
    public Result getCourseInfoListById(@PathVariable Long id){
        return Result.success(courseService.getCourseInfoListById(id));
    }

    @ApiOperation("根据课程id查询课程")
    @GetMapping("getClientCourseWxById/{id}")
    public Course getClientCourseWxById(@PathVariable("id") Long id){
        return courseService.getById(id);
    }
}
